<?php

namespace App\Utils;

use Illuminate\Http\Resources\MissingValue;

class MissingOrNot extends MissingValue
{
    protected $value;

    public function __construct($value)
    {
        $this->value = $value;
    }

    public function __get($name)
    {
        if ($this->value instanceof MissingValue) {
            return $this;
        }

        return $this->value->$name;
    }

    public function __call($name, $arguments)
    {
        if ($this->value instanceof MissingValue) {
            return $this;
        }

        return $this->value->$name(...$arguments);
    }
}